import request from '@/utils/request'

export function getGiftList (admin) {
  return request({
    url: admin ? '/v01/gift/all' : '/v01/gift/list',
    method: 'get'
  })
}

export function getGiftListByNamespace (namespace) {
  return request({
    url: '/v01/gift/all/printer',
    method: 'get',
    params: { namespace }
  })
}

export function getPriceList (admin) {
  return request({
    url: admin ? '/v01/gift_level_price/all' : '/v01/gift_level_price/list',
    method: 'get'
  })
}

export function createGift (resource, resourceDesc, costPrice, namespace) {
  return request({
    url: '/v01/gift/create/admin',
    method: 'post',
    data: {
      resource: resource,
      resourceDesc: resourceDesc,
      price: 0,
      costPrice: costPrice,
      namespace: namespace,
      status: 'ENABLE'
    }
  })
}

export function getGift (id) {
  return request({
    url: '/v01/gift/detail',
    method: 'get',
    params: {
      id
    }
  })
}
// export function updateGift (id, status) {
//   return request({
//     url: '/v01/gift/update/admin',
//     method: 'put',
//     // params: {
//     // },
//     data: {
//       id: id,
//       status: status
//     }
//   })
// }

export function updateGift (id, costPrice, status) {
  return request({
    url: '/v01/gift/update/admin',
    method: 'put',
    // params: {
    // },
    data: {
      id: id,
      costPrice: costPrice,
      status: status
    }
  })
}

export function createGiftPrice (data) {
  return request({
    url: '/v01/gift_level_price/create',
    method: 'post',
    data: data
  })
}

export function updateGiftPrice (id, price, status) {
  return request({
    url: '/v01/gift_level_price/update',
    method: 'put',
    data: {
      id: id,
      price: price,
      status: status
    }
  })
}
